import {
  checkUserName,
  certificationGong,
  certificationCai,
  login,
  userInfo,
  changeAvatar,
  goodsList,
  categoryList,
  cartList,
  addCart,
  deleteCart,
  comGoodsList,
  renew,
  reSetInfo,
  goodsDetail,
} from '@/http/api.js' //引入接口
const state = () => ({
  username: '',
})

const actions = {
  async checkUserApi(store, params) {
    return await checkUserName(params)
  },
  async certificationGongApi(store, params) {
    return await certificationGong(params)
  },
  async certificationCaiApi(store, params) {
    return await certificationCai(params)
  },
  async loginApi(store, params) {
    return await login(params)
  },
  async userInfoApi(store, params) {
    return await userInfo(params)
  },
  async changeAvatarApi(store, params) {
    return await changeAvatar(params)
  },
  async goodsListApi(store, params) {
    return await goodsList(params)
  },
  async categoryListApi(store, params) {
    return await categoryList(params)
  },
  async cartListApi(store, params) {
    return await cartList(params)
  },
  async addCartApi(store, params) {
    return await addCart(params)
  },
  async deleteCartApi(store, params) {
    return await deleteCart(params)
  },
  async comGoodsApi(store, params) {
    return await comGoodsList(params)
  },
  async renewApi(store, params) {
    return await renew(params)
  },
  async reSetInfoApi(store, params) {
    return await reSetInfo(params)
  },
  async goodsDetailApi(store, params) {
    return await goodsDetail(params)
  },
} //actions是vuex的内置对象  任意异步操作 说白了就是一个异步

export default {
  namespaced: true,
  state: state,
  actions, //简写
}
